Beginner's Guide to Android App Development: A Practical Approach for Beginners by Serhan Yamacli

Beginner's Guide to Android App Development: A Practical Approach for Beginners by Serhan Yamacli

Author:Serhan Yamacli [Yamacli, Serhan]
Language: eng
Format: epub, pdf
Published: 2017-06-29T07:00:00+00:00


String weightStr = weightText.getText().toString();

double weight = Double. parseDouble(heightStr);

Code 6.4

We now have weight and height data in double type variables so we can

do the BMI calculation using the equation given in the beginning of the

chapter as follows:

double BMI = (weight)/(height*height);

Code 6.5

In this code, the * operator does the multiplication while the / operator

divides the weight to the height squared.

We will display this BMI value in the EditText box next to the You BMI

label in the GUI. We did set its ID as BMIResult when we laid out the

user interface before. Therefore, the following code does this job:

final EditText BMIResult = (EditText)

findViewById(R.id. BMIResult);



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.